#include <fstream>
#include <ios>
#include <streambuf>
#include <fstream>
int main(int argc, const char** argv) {

    std::fstream fs("file", std::ios::in | std::ios::out | std::ios::binary | std::ios::app);

    fs.write("1", 1);

    std::filebuf buf;
    buf.open("file", std::ios::in | std::ios::out | std::ios::binary | std::ios::app);
    buf.sputc('2');

    fs.close();
    buf.close();

    return 0;
}